|
|
|
|
|
|
|
Run the SQLVB02.SQV script and check your results against the screen shown in Figure 13.9. |
|
|
|
|
|
|
|
|
Figure 13.9.
Results of the ALTER TABLE_DROP COLUMN keywords. |
|
|
|
|
| |
|
|
|
|
You can also use the ALTER TABLE statement to ADD or DROP CONSTRAINTs. We cover CONSTRAINTs in depth later in this chapter. |
|
|
|
|
|
|
|
|
|
|
Deleting Tables with DROP TABLE |
|
|
|
|
|
|
|
|
You can use the DROP TABLE statement to remove a table from the database. This is often used to remove temporary tables, or it can be used as part of a process that copies data from one table to another or from one database to another. Edit and save SQLVB02.SQV to match the code example in Listing 13.6. |
|
|
|
|
|
|
|
|
Listing 13.6. Using the DROP TABLE clause. |
|
|
|
|
|
|
|
|
//
// testing SQL Table Management Keywords
//
// create a new database for our tests
dbMake sqlvb02.mdb;
// create a simple table
CREATE TABLE NewTable
(Field1 TEXT(30) CONSTRAINT PKNewTable PRIMARY KEY,
Field2 INTEGER);
// add two new columns
ALTER TABLE NewTable ADD COLUMN Field3 DATE;
ALTER TABLE NewTable ADD COLUMN Field4 CURRENCY;
// drop one of the new columns
ALTER TABLE NewTable DROP COLUMN Field3;
// remove the table from the database
DROP TABLE NewTable;
// show the empty table
SELECT * FROM NewTable;
// eof |
|
|
|
|
|